﻿using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;

namespace TdxApiPool
{
    public class Config
    {

        private static readonly Root config= null;

        public static Root GetConfig()
        {
            return config;
        }
        
        static Config()
        {
            string currentDirectory = Environment.CurrentDirectory;
            var json = File.ReadAllText(currentDirectory + @"\config.json");
            config = JsonConvert.DeserializeObject<Root>(json);
        }
        
    }
    
    public class Host
    {
        /// <summary>
        /// 
        /// </summary>
        public string IpAddress { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int Port { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int ConnectCount { get; set; }
    }

    public class Query
    {
        /// <summary>
        /// 
        /// </summary>
        public Host Host { get; set; }
    }

    public class HostItem
    {
        /// <summary>
        /// 
        /// </summary>
        public string IpAddress { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int Port { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int ConnectCount { get; set; }
    }

    public class BaseMarket
    {
        /// <summary>
        /// 
        /// </summary>
        public List <HostItem > Host { get; set; }
    }
    
    public class Root
    {
        /// <summary>
        /// 
        /// </summary>
        public Query Query { get; set; }
        public String Redis{ get; set; }
        /// <summary>
        /// 
        /// </summary>
        public BaseMarket BaseMarket { get; set; }
        public BaseMarket FasterMarket{ get; set; }
    }
}